package gamesimulation;
import java.io.*;

public class question {
	String questiontext="";
	String answerA="", answerB="", answerC="", answerD="";
	String options="";
	double properties[][]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
	double mymodel[]={0,0,0,0};
	question(){
		questiontext="default constructor question";
		answerA="default constructor answer A";
		answerB="default constructor answer B";
		answerC="default constructor answer C";
		answerD="default constructor answer D";
		options="choose A, B, C, or D";
	}
	question(String q, String a, String b, String c, String d, double p[][], String o){
	
		questiontext=q;
		answerA=a;
		answerB=b;
		answerC=c;
		answerD=d;
		properties=p;
		options=o;
		
	}
	void askQuestion(stattrack stats){
		//take copy of old model data relevant
		//double model[]={0,0,0,0};//four values
		mymodel[0]=stats.gethappiness();
		mymodel[1]=stats.gethealth();
		mymodel[2]=stats.getluck();
		mymodel[3]=stats.getwealth();
		//display question text
		System.out.println(questiontext);
		System.out.println(answerA);
		System.out.println(answerB);
		System.out.println(answerC);
		System.out.println(answerD);
		//get response, apply anwer
		try {
		    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		    String str = "";
		    while (str != null) {
		        System.out.println(options);
		    	str = in.readLine();
		    	if(str.equals("a") || str.equals("A")){
		        	apply(properties[0]);
		        	break;
		        }
		        else if(str.equals("b") || str.equals("B")){
		        	apply(properties[1]);
		        	break;
		        }
		        else if(str.equals("c") || str.equals("C")){
		        	apply(properties[2]);
		        	break;
		        }
		        else if(str.equals("d") || str.equals("D")){
		        	apply(properties[3]);
		        	break;
		        }
		        else{
		        	System.out.println("you chose");
		        	System.out.println(str);
		        	System.out.println("That was not an option. Please pick a valid answer.");
		        }
		    }
		} catch (IOException e) {
		}
		//adjust model
		//apply changes
		if(mymodel[0]!=stats.gethappiness())
			stats.sethappiness(mymodel[0]);
		if(mymodel[1]!=stats.gethealth())
			stats.sethealth(mymodel[1]);
		if(mymodel[2]!=stats.getluck())
			stats.setluck(mymodel[2]);
		if(mymodel[3]!=stats.getwealth())
			stats.setwealth(mymodel[3]);
		
	}
	
	private void apply(double[] m){
		mymodel[0]+=m[0];
		mymodel[1]+=m[1];
		mymodel[2]+=m[2];
		mymodel[3]+=m[3];
		
	}
/*	private void applyb(double[] m){
		
	}
	private void applyc(double[] m){
		
	}
	private void applyd(double[] m){
		
	}
*/	
	int adjustModel(){
		return 0;
	}
}
